<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<?php

/*  Key:
0 : water
1 : land
2 : low-hill
3 : high-hill
4 : spawn         */

$map1 = array(
'name' => "Map1",
'height' => 24,
'width' => 6,
'mapData' => array (
0,0,0,0,0,0,
 1,0,0,0,1,
1,1,0,0,1,1,
 2,0,1,0,2,
2,1,1,1,1,2,
 2,1,1,1,2,
1,1,1,1,1,1,
 4,1,2,1,4,
1,1,2,2,1,1,
 1,1,2,1,1,
0,1,2,2,1,0,
 1,1,2,1,1,
0,1,3,3,1,0,
 0,1,3,1,0,
0,1,3,3,1,0,
 0,1,3,1,0,
0,1,1,1,1,0,
 1,1,0,1,0,
0,4,0,0,4,0,
 1,1,0,1,1,
0,1,1,1,1,0,
 0,0,1,0,0,
0,0,0,0,0,0,
 0,0,0,0,0,),
'players' => array('red', 'blue'),
'startLocation' => array(100,103));

?>
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <style type="text/css">
      @import url('css/game.css');
    </style>
    <title>Boardwinia!</title>
    <meta name="description" content=""/>

    <meta name="author" content="ImmortalNights"/>
    <meta name="copyright" content=""/>
    <meta name="keywords" content=""/>

    <meta name="robots" content="index,follow" />
    
    <link rel="shortcut icon" href="favicon.ico" />
    
    <script type="text/javascript" src="js/game.js"></script>
  </head>
  <body>
    <div class="header">
    </div>
    
    <div id="content">
      <?php
        
        function displayLocation($locationId, $topOffset, $tile, $locationStats) {
            $tileArray = array("water", "land", "hill", "mountain", "spawn");
            
            echo '<div id="location['.$locationId.']" class="locationDiv '.$tileArray[$tile].'" style="top:'.$topOffset.'px;" onmousedown="selectLocation(\''.$locationId.'\')">';
              echo '<input type="hidden" name="locationU['.$locationId.']" id="locationValueU['.$locationId.']" value="'.$locationStats['units'].'" />';
              echo '<input type="hidden" name="locationA['.$locationId.']" id="locationValueA['.$locationId.']" value="'.$locationStats['actionPoints'].'" />';
              echo '<input type="hidden" name="locationT['.$locationId.']" id="locationValueT['.$locationId.']" value="'.$locationStats['team'].'" />';
              echo '<div id="locationText['.$locationId.']" class="unit '.$locationStats['team'].'"/>'.$locationStats['units'].'</div>';
            echo '</div>';
        }
        
        function isStartLocation($mapDetails, $locationId) {
          $locationTeam = "none"; $locationUnits = 0;
          foreach ($mapDetails['startLocation'] as $key => $value) {
            if ($value == $locationId) {
              $locationTeam = $mapDetails['players'][$key];
              $locationUnits = 20;
              $locationActionPoints = 3;
            }
          }
          return array('team' => $locationTeam, 'units' => $locationUnits, 'actionPoints' => $locationActionPoints);
        }
        
        $topOffset = 0; $xOffset = - 0;
        echo '<div id="gameBoard" style="height:'.($map1['height'] * 34.7) .'px">';
          $dataCount = 0; 
          echo '<ul class="gameBounds">';
          for ($y = 1; $y <= $map1['height']; $y++) {
            echo "\n\t";
           
            echo '<li style="margin-left:'.$xOffset.'px">';
            
            $width = $map1['width'];
            $xOffset == 0 ? null : $width--;
            for ($x = 1; $x <= $width; $x++) {
                
                $locationStats = isStartLocation($map1,$dataCount);
                
                displayLocation($dataCount, $topOffset,  $map1['mapData'][$dataCount], $locationStats);
              
              $dataCount ++;
            }
            echo '</li>';
            $xOffset = 59 - $xOffset;
            $topOffset -= 32 ;
            
          }
          echo "</ul>";
        echo '</div>';
        echo "\n";
      ?>
      <h2>Boardwinia</h2>
      <div id="gameLog" style="height:<?php echo (($map1['height'] * 3) - 80); ?>px">
        
        <p>Welcome to Boardwinia</p>
      </div>
    </div>
    
    <div id="footer">
    </div>
  </body>
</html>

